﻿<UserControl x:Class="CmdletHelpEditor.UI.UserControls.EditorControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:viewModel="clr-namespace:CmdletHelpEditor.API.ViewModel"
			 xmlns:UserControls="clr-namespace:CmdletHelpEditor.UI.UserControls"
			 xmlns:converters="clr-namespace:CmdletHelpEditor.API.Converters"
			 xmlns:c="clr-namespace:CmdletHelpEditor.Controls"
			 mc:Ignorable="d"
			 d:DataContext="{d:DesignInstance c:ClosableTabItem}">
	<UserControl.Resources>
		<converters:NullToBooleanConverter x:Key="ToBooleanConverter"/>
		<Style x:Key="ItemContStyle" TargetType="{x:Type ListViewItem}">
			<Style.Triggers>
				<DataTrigger Binding="{Binding GeneralHelp.Status}" Value="Missing">
					<Setter Property="Foreground" Value="Red"/>
				</DataTrigger>
				<DataTrigger Binding="{Binding GeneralHelp.Status}" Value="New">
					<Setter Property="Foreground" Value="Blue"/>
				</DataTrigger>
				<DataTrigger Binding="{Binding GeneralHelp.Status}" Value="Valid">
					<Setter Property="Foreground" Value="Green"/>
				</DataTrigger>
			</Style.Triggers>
		</Style>
	</UserControl.Resources>
	<UserControl.Background>
		<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
			<GradientStop Color="#BCD5F6" Offset="0" />
			<GradientStop Color="#DCEBFD" Offset="1" />
		</LinearGradientBrush>
	</UserControl.Background>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="200" />
			<ColumnDefinition Width="auto" />
			<ColumnDefinition Width="*" />
		</Grid.ColumnDefinitions>
		<ListView Grid.Column="0"
		          DisplayMemberPath="Name"
				  SelectionMode="Single"
				  ItemsSource="{Binding Module.Cmdlets}"
				  SelectedItem="{Binding EditorContext.CurrentCmdlet}"
		          ItemContainerStyle="{StaticResource ResourceKey=ItemContStyle}">
			<ListView.ContextMenu>
				<ContextMenu StaysOpen="true">
					<MenuItem Header="Copy command name to clipboard"
							  Command="{x:Static viewModel:AppCommands.CopyToClipCommand}"
							  CommandParameter="{Binding EditorContext.CurrentCmdlet.Name}"/>
					</ContextMenu>
			</ListView.ContextMenu>
		</ListView>
		<GridSplitter Grid.Column="1" Width="5" ResizeBehavior="PreviousAndNext" HorizontalAlignment="Left" VerticalAlignment="Stretch" ResizeDirection="Columns"/>
		<TabControl Grid.Column="2" Background="#9FBEF4">
			<TabItem Header="General">
				<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
					<UserControls:GeneralControl VerticalAlignment="Top" HorizontalAlignment="Stretch" IsEnabled="{Binding EditorContext.GeneralTextBoxEnabled}"/>
				</ScrollViewer>
			</TabItem>
			<TabItem Header="Parameters">
				<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
					<UserControls:ParameterDescriptionControl VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
				</ScrollViewer>
			</TabItem>
			<TabItem Header="Examples">
				<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
					<UserControls:ExampleControl VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
				</ScrollViewer>
			</TabItem>
			<TabItem Header="Related Links">
				<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
					<UserControls:RelatedLinksControl VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
				</ScrollViewer>
			</TabItem>
			<TabItem Header="Support Information">
				<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
					<ScrollViewer.Style>
						<Style TargetType="ScrollViewer">
							<Setter Property="IsEnabled" Value="False" />
							<Style.Triggers>
								<MultiDataTrigger>
									<MultiDataTrigger.Conditions>
										<Condition Binding="{Binding Path=SelectedTab.Module.UseSupports}" Value="True" />
										<Condition Binding="{Binding Path=EditorContext.CurrentCmdlet, Converter={StaticResource ToBooleanConverter}}" Value="True" />
									</MultiDataTrigger.Conditions>
									<Setter Property="IsEnabled" Value="True" />
								</MultiDataTrigger>
							</Style.Triggers>
						</Style>
					</ScrollViewer.Style>
					<UserControls:SupportInfoControl  VerticalAlignment="Top" HorizontalAlignment="Center"/>
				</ScrollViewer>
			</TabItem>
			<TabItem Header="Output">
				<UserControls:DisplayOutputControl IsEnabled="{Binding EditorContext.GeneralTextBoxEnabled}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
			</TabItem>
			<TabItem Header="Advanced">
				<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
					<UserControls:AdvancedCmdletUC IsEnabled="{Binding EditorContext.GeneralTextBoxEnabled}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
				</ScrollViewer>
			</TabItem>
		</TabControl>
	</Grid>
</UserControl>
